import { Component ,} from '@angular/core';
import { IonicPage, NavController, NavParams, ToastController, AlertController } from 'ionic-angular';
//用户中心
import { UserinfoPage } from '../userinfo/userinfo';
//首页
import { HomePage } from '../home/home'; 
//登录
import { LoginPage } from '../login/login'; 
import { App } from '../../app/app.component'; 
//账号安全
import { AccountAndSafePage } from '../account-and-safe/account-and-safe';

//关于我们
import { AboutPage } from '../about/about';
/**
 * Generated class for the SettingPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-setting',
  templateUrl: 'setting.html',
})
export class SettingPage {


	constructor(public navCtrl: NavController, public navParams: NavParams, public toastCtrl: ToastController, public alertCtrl: AlertController,) {

		
	}

	ionViewDidLoad() {
		console.log('ionViewDidLoad SettingPage');
	}



	page(num){
		switch(num){
			case 0 :
				this.navCtrl.push(UserinfoPage)
				break;
			case 1 :
				this.navCtrl.push(AccountAndSafePage)
				break;
			//清楚缓存
			case 2 :
				let toast = this.toastCtrl.create({
					message: '清除成功',
					duration: 3000
				});
				toast.present();
				break; 
			case 3 :
				this.navCtrl.push(AboutPage);
				break;
		}
	}

	exit(){
		let confirm = this.alertCtrl.create({
			title: '温馨提示',
			message: '确定退出吗',
			buttons: [
				{
					text: '取消',
				},
				{
					text: '确认',
					handler: () => {
						console.log('退出');
						localStorage.clear()
						localStorage.setItem("loginState", "1")
						localStorage.setItem("laun", '1');
						localStorage.setItem("userName", "请登录")
						localStorage.setItem("userPic", "./assets/imgs/user.png")
						this.navCtrl.push(App);
						
					}
				}
			]
		});
		confirm.present();
	}

}
